package bm.com.project.server.sys.controller;

import bm.com.framework.common.config.EnumRoute;
import bm.com.project.server.sys.dto.BmSysUserDTO;
import bm.com.project.server.sys.entity.BmSysUserEntity;
import bm.com.project.server.sys.mapper.BmSysUserMapper;
import bm.com.framework.common.resp.ResultVO;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping(EnumRoute.SysRoute.Base)
public class SysUserController {

    @Resource
    BmSysUserMapper bmSysUserDao;

//    @Resource
//    ShiroService shiroService;

    /**
     * 获取用户详情
     * @return
     */
    @PostMapping(EnumRoute.SysRoute.User.GET_USER_DETAIL)
    public ResultVO getUserDetail(@RequestBody BmSysUserDTO bmSysUserDTO){
//        ValidatorUtils.validateEntity(bmSysUserDTO);
        BmSysUserEntity bmSysUserEntity = bmSysUserDao.selectById(bmSysUserDTO.getUserId());
        return ResultVO.success(bmSysUserEntity);
    }

    /**
     * 获取用户详情
     * @returnx
     */
    @PostMapping(EnumRoute.SysRoute.User.GET_USER_DETAIL_BY_TOKEN)
    public ResultVO getUserDetailByToken(HttpServletRequest request){

//        System.out.println(request);
//        String token = String.valueOf(request.getHeaders("token"));
//        if (Tool.isStringEmpty(token)){
//            return ResultVO.error("用户凭证不能为空");
//        }
//
//        System.out.println(token);
//        String userByToken = shiroService.findUserByToken(token);
//        log.info("用户token信息{}",userByToken);
//        if (Tool.isStringEmpty(userByToken)){
//            return ResultVO.error(EnumCode.UNAUTHORIZED,"用户认证失败，请从登录");
//        }

        return ResultVO.success("");
    }

}
